//
//  HYFStatusFrame.m
//  MyOCWeibo
//
//  Created by 黄勇锋 on 16/10/8.
//  Copyright © 2016年 黄勇锋. All rights reserved.
//

#import "HYFStatusFrame.h"

#define Margin 10
#define HeadImageW  35


@implementation HYFStatusFrame

- (void)setStates:(HYFStates *)states{
    
    _states = states;
    //计算子控件的大小
    
    //头像
    CGFloat headImageX = Margin;
    CGFloat headImageY = Margin;
    CGSize headImageSize = CGSizeMake(HeadImageW, HeadImageW);
    
    self.headImageViewF = (CGRect){{headImageX,headImageY},headImageSize};
    
    //昵称
    CGFloat nameLabelX = CGRectGetMaxX(self.headImageViewF) + Margin;
    CGFloat nameLabelY = headImageY;
    CGSize nameLabelSize = [states.user.screen_name sizeWithFont:SYS_FONT(NAME_LABEL_FONT)];
    
    self.nameLabelF = (CGRect){{nameLabelX,nameLabelY},nameLabelSize};
    
    //时间
   
    CGFloat timeLabelX = nameLabelX;
    CGFloat timeLabelY = CGRectGetMaxY(self.nameLabelF) + Margin * 0.5;
    CGSize timeLabelSize = [states.created_at sizeWithFont:SYS_FONT(TIME_LABEL_FONT)];
    
    self.timeLabelF = (CGRect){{timeLabelX,timeLabelY},timeLabelSize};
    
     //来源
    CGFloat sourceLabelX = CGRectGetMaxX(self.timeLabelF) + Margin;
    CGFloat sourceLabelY = timeLabelY;
    CGSize sourceLabelSize = [states.source sizeWithFont:SYS_FONT(TIME_LABEL_FONT)];
    
    self.sourceLabelF = (CGRect){{sourceLabelX,sourceLabelY},sourceLabelSize};
    
    //原创微博文字内容
    CGFloat contentLabelX = headImageX;
    CGFloat contentLabelY = CGRectGetMaxY(self.headImageViewF) + Margin;
    //根据文字内容确定 size 大小
    CGSize contentLabelSize =  [states.text sizeWithFont:SYS_FONT(CONTENT_LABEL_FONT) constrainedToSize:CGSizeMake(SCREEN_WIDTH - 2 * Margin, MAXFLOAT)];
    
    self.contentLabelF = (CGRect){{contentLabelX,contentLabelY},contentLabelSize};
    
    //原创微博配图内容
    //判断是否有图片
    
    //底部 转发,评论,赞
    CGFloat toolBarX = 0;
    CGFloat toolBarY = CGRectGetMaxY(self.contentLabelF) + Margin;
    
    if (states.thumbnail_pic) {
        
        CGFloat originalImageX = headImageX;
        CGFloat originalImageY = CGRectGetMaxY(self.contentLabelF) + Margin;
        //根据文字内容确定 size 大小
        CGSize originalImageSize = CGSizeMake(100, 100);
        
        self.originalImageViewF = (CGRect){{originalImageX,originalImageY},originalImageSize};
        
        toolBarY = CGRectGetMaxY(self.originalImageViewF) + Margin;
        
    }else{
        
    }
    
    //根据文字内容确定 size 大小
    CGSize toolBarSize = CGSizeMake(SCREEN_WIDTH, 35);
    
    self.toolBarF = (CGRect){{toolBarX,toolBarY},toolBarSize};
    
    self.cellHeight = CGRectGetMaxY(self.toolBarF);
}



@end
